package dyyx.rule;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class RuleSqlContext {
	
	private static final String SEP = ";\n";
	
	public int count = 1;

	private final AtomicInteger ruleDisplayOrder = new AtomicInteger(0);

	
	public String policySetUuid;
	public String eventId;
	public String policyUuid;
	public String ruleUuid;
	public String ruleConditionParentUuid;
	public String ruleConditionUuid;

	
	
	public String policySetSql;
	
	public String policySql;
	

	
    public final List<String> ruleSqls = new ArrayList<String>();
    
    
    public int getRuleDisplayOrder(){
    	return ruleDisplayOrder.get();
    }
    
    
    public String toSql(){
    	StringBuilder sb = new StringBuilder();
    	
    	if(policySetSql!=null){
    		sb.append(policySetSql).append(SEP);
    	}
    	if(policySql!=null){
    		sb.append(policySql).append(SEP);
    	}
    	
    	for(String item:ruleSqls){
    		sb.append(item).append(SEP);

    	}
    	
    	return sb.toString();
    }
	
	
}
